]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Use paint and pick context to get framebuffer
authorJonas Ådahl <jadahl@gmail.com>
Fri, 22 Nov 2019 17:36:17 +0000 (18:36 +0100)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 3 Dec 2019 19:07:15 +0000 (19:07 +0000)
Mutter and Clutter was changed to pass around the current target
framebuffer via the paint context instead of via the deprecated Cogl
framebuffer stack.

The framebuffer stack has also been removed from Cogl so change to use
the one in the paint context instead.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/827

js/ui/lookingGlass.js
src/shell-glsl-effect.c
src/shell-invert-lightness-effect.c
src/st/st-box-layout.c
src/st/st-entry.c
src/st/st-icon.c
src/st/st-label.c
src/st/st-private.c
src/st/st-widget.c
tests/interactive/background-size.js

index 19a9396d436e882347814aeb47e0241e08ded546..ac25c7b73d6b883e553d418184d5152392193a55 100644 (file)
@@ -472,25 +472,40 @@ class ObjInspector extends St.ScrollView {
 
 var RedBorderEffect = GObject.registerClass(
 class RedBorderEffect extends Clutter.Effect {
+    _init() {
+        super._init();
+        this._pipeline = null;
+    }
+
     vfunc_paint(paintContext) {
+        let framebuffer = paintContext.get_framebuffer();
+        let coglContext = framebuffer.get_context();
         let actor = this.get_actor();
         actor.continue_paint(paintContext);
 
-        let color = new Cogl.Color();
-        color.init_from_4ub(0xff, 0, 0, 0xc4);
-        Cogl.set_source_color(color);
+        if (!this._pipeline) {
+            let color = new Cogl.Color();
+            color.init_from_4ub(0xff, 0, 0, 0xc4);
+
+            this._pipeline = new Cogl.Pipeline(coglContext);
+            this._pipeline.set_color(color);
+        }
 
         let alloc = actor.get_allocation_box();
         let width = 2;
 
         // clockwise order
-        Cogl.rectangle(0, 0, alloc.get_width(), width);
-        Cogl.rectangle(alloc.get_width() - width, width,
-                       alloc.get_width(), alloc.get_height());
-        Cogl.rectangle(0, alloc.get_height(),
-                       alloc.get_width() - width, alloc.get_height() - width);
-        Cogl.rectangle(0, alloc.get_height() - width,
-                       width, width);
+        framebuffer.draw_rectangle(this._pipeline,
+            0, 0, alloc.get_width(), width);
+        framebuffer.draw_rectangle(this._pipeline,
+            alloc.get_width() - width, width,
+            alloc.get_width(), alloc.get_height());
+        framebuffer.draw_rectangle(this._pipeline,
+            0, alloc.get_height(),
+            alloc.get_width() - width, alloc.get_height() - width);
+        framebuffer.draw_rectangle(this._pipeline,
+            0, alloc.get_height() - width,
+            width, width);
     }
 });
 
index 6347dbf9c671603a94b6c4c60324cd80bbb17638..8f4bd2aaf93ccbdf89db71e80a689cc0c6514c89 100644 (file)
@@ -74,6 +74,7 @@ shell_glsl_effect_paint_target (ClutterOffscreenEffect *effect,
   ShellGLSLEffectPrivate *priv;
   ClutterActor *actor;
   guint8 paint_opacity;
+  CoglFramebuffer *framebuffer;
 
   priv = shell_glsl_effect_get_instance_private (self);
 
@@ -85,7 +86,9 @@ shell_glsl_effect_paint_target (ClutterOffscreenEffect *effect,
                               paint_opacity,
                               paint_opacity,
                               paint_opacity);
-  cogl_framebuffer_draw_rectangle (cogl_get_draw_framebuffer (),
+
+  framebuffer = clutter_paint_context_get_framebuffer (paint_context);
+  cogl_framebuffer_draw_rectangle (framebuffer,
                                    priv->pipeline,
                                    0, 0,
                                    priv->tex_width, priv->tex_height);
index 282725b22528c2857007698210f8f755054f2f58..bb0e97961a77f8150c6224bc0aa423d4bb5ecbaf 100644 (file)
@@ -124,7 +124,7 @@ shell_invert_lightness_effect_paint_target (ClutterOffscreenEffect *effect,
   ShellInvertLightnessEffect *self = SHELL_INVERT_LIGHTNESS_EFFECT (effect);
   ClutterActor *actor;
   guint8 paint_opacity;
-  CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
+  CoglFramebuffer *fb = clutter_paint_context_get_framebuffer (paint_context);
 
   actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (effect));
   paint_opacity = clutter_actor_get_paint_opacity (actor);
index 66b17b185b902c916464668fecb3700c305aead6..019aebd76a23b83841c6f43e734b0ff0b8bc31f6 100644 (file)
@@ -397,7 +397,7 @@ st_box_layout_paint (ClutterActor        *actor,
   ClutterActorBox allocation_box;
   ClutterActorBox content_box;
   ClutterActor *child;
-  CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
+  CoglFramebuffer *fb = clutter_paint_context_get_framebuffer (paint_context);
 
   get_border_paint_offsets (self, &x, &y);
   if (x != 0 || y != 0)
@@ -454,7 +454,7 @@ st_box_layout_pick (ClutterActor       *actor,
   ClutterActorBox allocation_box;
   ClutterActorBox content_box;
   ClutterActor *child;
-  CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
+  CoglFramebuffer *fb = clutter_pick_context_get_framebuffer (pick_context);
 
   get_border_paint_offsets (self, &x, &y);
   if (x != 0 || y != 0)
index 9c45fbd654f58502b5d3384a4ec1ee349dcba635..cb75273b5dc310d076f600bec09c2fed77466f40 100644 (file)
@@ -877,11 +877,16 @@ st_entry_paint (ClutterActor        *actor,
         }
 
       if (priv->text_shadow_material != NULL)
-        _st_paint_shadow_with_opacity (shadow_spec,
-                                       cogl_get_draw_framebuffer (),
-                                       priv->text_shadow_material,
-                                       &allocation,
-                                       clutter_actor_get_paint_opacity (priv->entry));
+        {
+          CoglFramebuffer *framebuffer =
+            clutter_paint_context_get_framebuffer (paint_context);
+
+          _st_paint_shadow_with_opacity (shadow_spec,
+                                         framebuffer,
+                                         priv->text_shadow_material,
+                                         &allocation,
+                                         clutter_actor_get_paint_opacity (priv->entry));
+        }
     }
 
   /* Since we paint the background ourselves, chain to the parent class
index fc6aa512387916dc5dc2debc05b21ac46192ebfe..133209d1e6bc02184a39d68b13e90b0a92241c10 100644 (file)
@@ -178,10 +178,12 @@ st_icon_paint (ClutterActor        *actor,
       if (priv->shadow_pipeline)
         {
           ClutterActorBox allocation;
+          CoglFramebuffer *framebuffer;
 
           clutter_actor_get_allocation_box (priv->icon_texture, &allocation);
+          framebuffer = clutter_paint_context_get_framebuffer (paint_context);
           _st_paint_shadow_with_opacity (priv->shadow_spec,
-                                         cogl_get_draw_framebuffer (),
+                                         framebuffer,
                                          priv->shadow_pipeline,
                                          &allocation,
                                          clutter_actor_get_paint_opacity (priv->icon_texture));
index 42816ffdf2343e48db8fc1099a6d25543bfcf8f3..947c8ec8613337e11ea6ec176f48d7ae6794b0ce 100644 (file)
@@ -229,11 +229,17 @@ st_label_paint (ClutterActor        *actor,
             }
 
           if (priv->text_shadow_pipeline != NULL)
-            _st_paint_shadow_with_opacity (shadow_spec,
-                                           cogl_get_draw_framebuffer (),
-                                           priv->text_shadow_pipeline,
-                                           &allocation,
-                                           clutter_actor_get_paint_opacity (priv->label));
+            {
+              CoglFramebuffer *framebuffer;
+
+              framebuffer =
+                clutter_paint_context_get_framebuffer (paint_context);
+              _st_paint_shadow_with_opacity (shadow_spec,
+                                             framebuffer,
+                                             priv->text_shadow_pipeline,
+                                             &allocation,
+                                             clutter_actor_get_paint_opacity (priv->label));
+            }
         }
     }
 
index fd2cc39b1d64a3fe11860956198b6e36d83125c8..3107a0cf2dcfad2b1d933809b4913761baf343d9 100644 (file)
@@ -490,12 +490,6 @@ _st_create_shadow_pipeline_from_actor (StShadow     *shadow_spec,
       cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
       clutter_actor_get_position (actor, &x, &y);
 
-      /* XXX: There's no way to render a ClutterActor to an offscreen
-       * as it uses the implicit API. */
-      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-      cogl_push_framebuffer (fb);
-      G_GNUC_END_IGNORE_DEPRECATIONS;
-
       cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color);
       cogl_framebuffer_translate (fb, -x, -y, 0);
       cogl_framebuffer_orthographic (fb, 0, 0, width, height, 0, 1.0);
@@ -507,10 +501,6 @@ _st_create_shadow_pipeline_from_actor (StShadow     *shadow_spec,
       clutter_actor_paint (actor, paint_context);
       clutter_paint_context_destroy (paint_context);
 
-      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-      cogl_pop_framebuffer ();
-      G_GNUC_END_IGNORE_DEPRECATIONS;
-
       clutter_actor_set_opacity_override (actor, -1);
 
       cogl_object_unref (fb);
index dd11f8ad119c914c5b29383ed01c2c447ab63a31..26eccee1f428a7f299e8e5127a8150f513708345 100644 (file)
@@ -416,7 +416,7 @@ st_widget_paint_background (StWidget            *widget,
   if (!st_widget_get_resource_scale (widget, &resource_scale))
     return;
 
-  framebuffer = cogl_get_draw_framebuffer ();
+  framebuffer = clutter_paint_context_get_framebuffer (paint_context);
   theme_node = st_widget_get_theme_node (widget);
 
   clutter_actor_get_allocation_box (CLUTTER_ACTOR (widget), &allocation);
index 7b18f895013a07093cbdedee7998192b5caaef9f..064bc9e868d856ae56e186f743778340d1abc98d 100644 (file)
@@ -2,11 +2,13 @@
 
 const UI = imports.testcommon.ui;
 
-const { Cogl, Clutter, St } = imports.gi;
+const { Cogl, Clutter, Meta, St } = imports.gi;
 
 
 function test() {
-    let stage = new Clutter.Stage({ user_resizable: true, width: 1024, height: 768 });
+    Meta.init();
+
+    let stage = Meta.get_backend().get_stage();
     UI.init(stage);
 
     let vbox = new St.BoxLayout({ style: 'background: #ffee88;' });
@@ -33,20 +35,32 @@ function test() {
         if (useCairo)
             obin.style = 'border: 3px solid green;';
         else
-            obin.connect_after('paint', actor => {
-                Cogl.set_source_color4f(0, 1, 0, 1);
+            obin.connect_after('paint', (actor, paintContext) => {
+                let framebuffer = paintContext.get_framebuffer();
+                let coglContext = framebuffer.get_context();
+
+                let pipeline = new Cogl.Pipeline(coglContext);
+                pipeline.set_color4f(0, 1, 0, 1);
 
                 let alloc = actor.get_allocation_box();
                 let width = 3;
 
                 // clockwise order
-                Cogl.rectangle(0, 0, alloc.get_width(), width);
-                Cogl.rectangle(alloc.get_width() - width, width,
-                               alloc.get_width(), alloc.get_height());
-                Cogl.rectangle(0, alloc.get_height(),
-                               alloc.get_width() - width, alloc.get_height() - width);
-                Cogl.rectangle(0, alloc.get_height() - width,
-                               width, width);
+                framebuffer.draw_rectangle(pipeline,
+                                           0, 0, alloc.get_width(), width);
+                framebuffer.draw_rectangle(pipeline,
+                                           alloc.get_width() - width, width,
+                                           alloc.get_width(), alloc.get_height());
+                framebuffer.draw_rectangle(pipeline,
+                                           0,
+                                           alloc.get_height(),
+                                           alloc.get_width() - width,
+                                           alloc.get_height() - width);
+                framebuffer.draw_rectangle(pipeline,
+                                           0,
+                                           alloc.get_height() - width,
+                                           width,
+                                           width);
             });
         tbox.add(obin);